<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        // const p = new Promise((resolve, reject)=>{
        //     //同步调用
        //     // resolve()
        //     reject('失败')
        // })

        // //执行catch方法
        // p.catch(reason=>{
        //     console.log(reason)
        // })
        

        // Promise函数的resolve方法
        // let p1 = Promise.resolve(521)
        // 如果传入的参数为 非Promsie 类型的对象,则返回的结果为成功的promise对象
        // 如果传入的参数为 Promise对象, 则参数的结果决定 resolve的结果
        // console.log(p1)
        // let p2 = Promise.resolve(new Promise((resolve,reject)=>{
            // resolve()
            // reject()
        // }))
        // console.log(p2)
        // p2.catch(reason=>{
        //     console.log(reason)
        // })



        // Promise函数的reject方法
        // let p = Promise.reject(51)
        // let p2 = Promise.reject('是的了')
        // let p3 = Promise.reject(new Promise((resolve,reject)=>{
        //     resolve()
        // }))
        // console.log(p3)


        // Promise函数的all方法
        let p1 = new Promise((resolve, reject)=>{
            resolve('ok')
        })
        let p2 = Promise.resolve('success1')
        let p3 = ''
        // let p3 = Promise.reject('123')
        const res = Promise.all([p1,p2,p3])
        console.log('res',res)

        
        // Promise函数的race方法

        // let p1 = Promise.resolve('success1')
        // let p2 = Promise.resolve('success2')
        // let p3 = Promise.reject('123')
        // const res = Promise.race([p3,p2,p1])
        // console.log(res)



    </script>
</body>
</html>